const db = wx.cloud.database()
const array = db.collection('Articals')

Page({
  data: {
    loadingFlag: 'false',
  },
  //生命周期函数--监听页面加载
  onLoad: function (options) {
    let that = this
    // 动画显示
    that.setData({
      loadingFlag: true
    });
    setTimeout(function () {
      that.setData({
        loadingFlag: false
      })
    }, 2000) //动画延时3s

    let id = options.id
    var newarticle = wx.getStorageSync(id)
    if (newarticle != '') {
      this.setData({
        isAdd: true,
        pages: newarticle
      })
    } else {
      array.doc(id).get({
        success: res => {
          this.setData({
            pages: res.data,
            isAdd: false
          })
        }
      })
    }

  },
})